//
//  String+Category.swift
//  WeiBoOfSwift
//
//  Created by aven wu on 24/04/2018.
//  Copyright © 2018 GML. All rights reserved.
//

import UIKit
extension String{
    /*
     将当前字符串拼接到cache目录下
     */
    func cacheDir() -> String {
        
        let path =  NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last
        return (path! as NSString).appendingPathComponent((self as NSString).lastPathComponent)
    }
    
    /*
     将当前字符串拼接到document目录下
     */
    func documentDir() -> String {
        
        let path =  NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last
        return (path! as NSString).appendingPathComponent((self as NSString).lastPathComponent)
    }
    
    /*
     将当前字符串拼接到document目录下
     */
    func tmpDir() -> String {
        
        let path =  NSTemporaryDirectory()
        return (path as NSString).appendingPathComponent((self as NSString).lastPathComponent)
    }
    
    
}
